package TowDer.TowerEnemys;

import javax.swing.JLabel;

import TowDef.generic.Enemy;
import TowDef.generic.Map;

/*
 * Hilo para mover y controlar los labels del enemigo y controlar cuando mueren.
 */
public class Move extends Thread{
	
	private Enemy enemy;
	private JLabel img;
	private Map map;
	
	public Move(Enemy enemy, JLabel img, Map map)
	{
		this.map = map;
		this.img = img;
		this.enemy = enemy;
	}
	@SuppressWarnings("deprecation")
	public void run(){
		int contador = 0;
		
		while(enemy.getLife()>0&&img.getX()<200){
			img.setBounds(img.getX()+2,img.getY(),30,30);
			try {
				Thread.sleep(50);
				contador++;
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(contador ==10){
				contador = 0;
				enemy.move();
			}
		}
	}
	
	
	

}
